package com.example.hello;

import com.example.hello.client.NavSearch.BootstrapNavSearchState;
import com.vaadin.ui.AbstractComponent;

public class BootstrapNavSearch extends AbstractComponent {

    public BootstrapNavSearch() {
        this(0);
    }

    public BootstrapNavSearch(int size) {
        this("", size);
    }

    public BootstrapNavSearch(String placeholder, int size) {
        this(placeholder, BootstrapNav.Alignment.NONE, size);
    }

    public BootstrapNavSearch(String placeholder, BootstrapNav.Alignment alignment, int size) {
        this(placeholder, alignment, BootstrapForm.Type.SEARCH, size);
    }

    public BootstrapNavSearch(String placeholder, BootstrapNav.Alignment alignment, BootstrapForm.Type type, int size) {
        setPlaceholder(placeholder);
        setAlignment(alignment);
        setType(type);
        setSize(size);
        setHeight("100%");

        setImmediate(true);
    }

    @Override
    protected BootstrapNavSearchState getState() {
        return (BootstrapNavSearchState) super.getState();
    }

    public String getPlaceholder() {
        return getState().getPlaceholder();
    }

    public void setPlaceholder(String placeholder) {
        getState().setPlaceholder(placeholder);
    }

    public BootstrapNav.Alignment getAlignment() {
        return BootstrapNav.Alignment.valueOf(getState().getAlignment());
    }

    public void setAlignment(BootstrapNav.Alignment alignment) {
        getState().setAlignment(alignment.toString());
    }

    public BootstrapForm.Type getType() {
        return BootstrapForm.Type.valueOf(getState().getType());
    }

    public void setType(BootstrapForm.Type type) {
        getState().setType(type.toString());
    }

    public int getSize() {
        return getState().getSize();
    }

    public void setSize(int size) {
        getState().setSize(size);
    }

}